package com.mzj.saas.mservice.house.controller;

import com.mzj.saas.commons.ResultBean;
import com.mzj.saas.mservice.house.service.LockService;
import com.mzj.saas.mservice.house.vo.LockAuditVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/lock")
public class LockController {

    @Autowired
    private LockService lockService;

    /**
     * 智能锁授权信息
     *
     * @param houseId
     * @return
     */
    @GetMapping("/findLockAudit")
    @ResponseBody
    public ResultBean<List<LockAuditVO>> findLockAudit(@RequestParam(value = "houseId") String houseId) {
        return lockService.findLockAudit(houseId);
    }

    /**
     * 授权
     *
     * @param id
     * @return
     */
    @GetMapping("/authorize")
    @ResponseBody
    public ResultBean<Object> authorize(@RequestHeader String accessToken, @RequestParam(value = "id") Long id) {
        return lockService.authorize(accessToken, id);
    }

    /**
     * 冻结
     *
     * @param houseId
     * @param reason
     * @return
     */
    @GetMapping("/freeze")
    @ResponseBody
    public ResultBean<Object> freeze(@RequestHeader String accessToken,
                                     @RequestParam(value = "houseId") String houseId,
                                     @RequestParam(value = "reason") String reason) {
        return lockService.freeze(accessToken, houseId, reason);
    }

    /**
     * 解冻
     *
     * @param houseId
     * @return
     */
    @GetMapping("/unfreeze")
    @ResponseBody
    public ResultBean<Object> unfreeze(@RequestParam(value = "houseId") String houseId) {
        return lockService.unfreeze(houseId);
    }


}
